6dofimu9 2.2.0
6dofimu9


6DOF IMU 9 Click

6DOF IMU 9 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.


Click Library

  • Author : MikroE Team
  • Date : dec 2019.
  • Type : I2C/SPI type

Software Support

Example Description

This application measure 3-axis gyroscope and a 3-axis accelerometer.

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.6DOFIMU9

Example Key Functions

Application Init

Initialization driver enables - I2C, check device ID, configure accelerometer and gyroscope, also write log.

void application_init ( void )
{
log_cfg_t log_cfg;
uint8_t device_id;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
// Click initialization.
C6DOFIMU9_MAP_MIKROBUS( cfg, MIKROBUS_1 );
c6dofimu9_init( &c6dofimu9, &cfg );
log_printf( &logger, " Driver Initialization \r\n" );
log_printf( &logger, "-------------------------------------\r\n" );
Delay_100ms( );
device_id = c6dofimu9_get_device_id( &c6dofimu9 );
if ( device_id == C6DOFIMU9_DEVICE_ID )
{
log_printf( &logger, " SUCCESS \r\n" );
log_printf( &logger, "-------------------------------------\r\n" );
}
else
{
log_printf( &logger, " ERROR \r\n" );
log_printf( &logger, " RESET DEVICE \r\n" );
log_printf( &logger, "-----------------------------------\r\n" );
for ( ; ; );
}
log_printf( &logger, " Start measurement \r\n" );
log_printf( &logger, "-------------------------------------\r\n" );
Delay_100ms( );
}
#define C6DOFIMU9_ACCEL_AVERAGE_4_SAMPLES
Definition c6dofimu9.h:207
#define C6DOFIMU9_ACCEL_FULL_SCALE_2g
Definition c6dofimu9.h:203
#define C6DOFIMU9_DEVICE_ID
Definition c6dofimu9.h:247
#define C6DOFIMU9_GYRO_FULL_SCALE_250dps
Definition c6dofimu9.h:193
#define C6DOFIMU9_GYRO_AVERAGE_1x
Definition c6dofimu9.h:217
#define C6DOFIMU9_MAP_MIKROBUS(cfg, mikrobus)
Definition c6dofimu9.h:67
void c6dofimu9_set_gyro_config_lp_mode(c6dofimu9_t *ctx, uint8_t gyro_averages)
Generic read function.
uint8_t c6dofimu9_get_device_id(c6dofimu9_t *ctx)
Get device ID function.
void c6dofimu9_set_accel_avg_filter_mode(c6dofimu9_t *ctx, uint8_t accel_avg_samples)
Set Accel averaging filter settings for Low Power mode function.
void application_init(void)
Definition main.c:36

Application Task

This is an example which demonstrates the use of 6DOF IMU 9 Click board. Measured and display Accel and Gyro data coordinates values for X-axis, Y-axis and Z-axis. Results are being sent to the Usart Terminal where you can track their changes. All data logs write on USB uart changes for every 1 sec.

{
int16_t accel_axis_x;
int16_t accel_axis_y;
int16_t accel_axis_z;
int16_t gyro_axis_x;
int16_t gyro_axis_y;
int16_t gyro_axis_z;
c6dofimu9_get_accel_data( &c6dofimu9, &accel_axis_x, &accel_axis_y, &accel_axis_z );
Delay_10ms( );
c6dofimu9_get_gyro_data( &c6dofimu9, &gyro_axis_x, &gyro_axis_y, &gyro_axis_z );
Delay_10ms( );
log_printf( &logger, " Accel X : %d ", accel_axis_x );
log_printf( &logger, " | ");
log_printf( &logger, " Gyro X : %d \r\n", gyro_axis_x );
log_printf( &logger, " Accel Y : %d ", accel_axis_y );
log_printf( &logger, " | ");
log_printf( &logger, " Gyro Y : %d \r\n", gyro_axis_y);
log_printf( &logger, " Accel Z : %d ", accel_axis_z );
log_printf( &logger, " | ");
log_printf( &logger, " Gyro Z : %d \r\n", gyro_axis_z);
log_printf(&logger, "-------------------------------------\r\n");
Delay_1sec( );
}
void c6dofimu9_get_accel_data(c6dofimu9_t *ctx, int16_t *p_accel_x, int16_t *p_accel_y, int16_t *p_accel_z)
Read Accel X-axis, Y-axis and Z-axis axis function.
void c6dofimu9_get_gyro_data(c6dofimu9_t *ctx, int16_t *p_gyro_x, int16_t *p_gyro_y, int16_t *p_gyro_z)
Read Gyro X-axis, Y-axis and Z-axis axis function.
void application_task()
Definition main.c:90

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
  • UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.

Additional Notes and Information

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.